from rankinglistspider.db import db, category_tables


def get_category_id(category):
    for category_name, category_values in category_tables.items():
        if category in category_values:
            category_info = db.category_info.find_one({'name': category_name})
            return category_info['_id']
    return None


if __name__ == '__main__':
    print(get_category_id('娱乐'))
